package com.hl.qzzpbackend.model.enums;
import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/**
 * 公司类型枚举
 * @author helong
 */
@Getter
public enum CompanyTypeEnum {
    PRIVATE_ENTERPRISE(0, "民营企业"),
    STATE_OWNED(1, "国有企业"),
    FOREIGN_ENTERPRISE(2, "外资企业"),
    JOINT_VENTURE(3, "合资企业");

    private final Integer value;
    private final String text;

    // 构造函数
    CompanyTypeEnum(Integer value, String text) {
        this.value = value;
        this.text = text;
    }


    /**
     * 根据value获取枚举
     * @param value 枚举值的value
     * @return 枚举值
     */
    public static CompanyTypeEnum getEnumByValue(Integer value) {
        if(ObjUtil.isEmpty(value)) {
            return null;
        }
        for (CompanyTypeEnum companyTypeEnum : CompanyTypeEnum.values()) {
            if (companyTypeEnum.getValue().equals(value)) {
                return companyTypeEnum;
            }
        }
        return null;
    }
}